package net.vanchu.mortgagecalculator.mortgage.data.calculator;

/**
 * Created by Granton on 2016/12/21.
 */
public class PBalancedCalculator {

    public static double calFirstRepayNumber(double principal, double monthRate, int numberOfMonths) {
        return (principal / numberOfMonths + principal * monthRate);
    }

    public static double calDecreaseNumber(double principal, double monthRate, int numberOfMonths) {
        return (principal / numberOfMonths * monthRate);
    }

    public static double calTotalInterest(double principal, double monthRate, int numberOfMonths) {
        return principal * monthRate * (numberOfMonths + 1) / 2;
    }

    public static double calInterestCurrentMonth(double remainPrincipal, double monthRate) {
        return remainPrincipal * monthRate;
    }

    public static double calRemainPrincipal(double principal, double principalToPayPerMonth, int numberOfMonths) {
        return principal - principalToPayPerMonth * numberOfMonths;
    }

    public static double calPrincipalPerMonth(double principal, int numberOfMonths) {
        return principal / numberOfMonths;
    }
}